<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<h2>当前计数: {{counter}}</h2>
			<!-- 直接写法 -->
			<button type="button" v-on:click="counter++">+</button>
			<button type="button" v-on:click="counter--">-</button>
			<!-- 函数写法 -->
			<button type="button" v-on:click="add">+</button>
			<button type="button" v-on:click="sub">-</button>
			<!-- 语法糖写法 -->
			<button type="button" @click="add">+</button>
			<button type="button" @click="sub">-</button>
		</div>
	</body>
	<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		const app = new Vue({
			el: "#app",
			data: {
				counter:0
			},
			methods:{
				add:function(){
					this.counter++;
					console.log('add被执行');
				},
				sub:function(){
					this.counter--;
					console.log('sub被执行');
				}
			}
		})
	</script>
</html>
